package com.learn.training.multithread.chapter7.demo2;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class Demo {
    public static void main(String[] args) throws InterruptedException {
        ScheduledExecutorService ses = Executors.newScheduledThreadPool(6);
        for(int i =0; i < 6; i++){
            ses.scheduleAtFixedRate(new Task("task" + i), 2 , 3, TimeUnit.SECONDS);
        }
        // 这里的线程池会一直存在，直到调用shutdown()方法，才会关闭
//        ses.shutdown();
        //关闭线程池
    }
}
